package com.example.demo;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;

/**
 * @author ml
 * @create 2017-07-14--10:55
 * @EnableWebSocketMessageBroker注解开启使用STOMP协议来传输消息，
 * 并且实现了registerStompEndpoints方法添加了对应的STOMP使用SockJS协议。
 * 接下来我们配置两个实体用于浏览器与服务器端的通信交互。
 */
@Configuration
@EnableWebSocketMessageBroker
public class WebSockerConfig extends AbstractWebSocketMessageBrokerConfigurer {
    @Override
    public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
        stompEndpointRegistry.addEndpoint("/endpointWisely").withSockJS();

    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.enableSimpleBroker("/topic");
    }
}
